home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
Libraries
/
Dots & Pixels
/
sources
/
soundchannel.cp
< prev
next >
Wrap
Text File
|
1995-09-29
|
1KB
|
66 lines
#include <Types.h>
#include <Resources.h>
#include <QuickDraw.h>
#include <ToolUtils.h>
#include <Sound.h>
#include "soundchannel.h"
soundchannel::soundchannel()
{
OSErr result;
thechannel = 0L;
result = SndNewChannel( &thechannel, squareWaveSynth, 0, 0L);
if( result != noErr)
{
DebugStr( "\pSndNewChannel failed");
}
}
soundchannel::~soundchannel()
{
(void)SndDisposeChannel( thechannel, true);
}
void soundchannel::playsound( const int resno) const
{
playsound( (SndListHandle)Get1Resource( 'snd ', resno));
}
void soundchannel::playsound( SndListHandle thesound) const
{
//
// NB: we do not use our own sound channel here (it is linked
// to the square wave synthesizer and cannot play all sounds)
//
SndPlay( 0L, thesound, false);
}
void soundchannel::setamplitude( unsigned char amp) const
{
sendcommand( ampCmd, amp, 0);
}
void soundchannel::sendcommand( short cmd, short param1, long param2) const
{
SndCommand thecommand;
thecommand.cmd = cmd;
thecommand.param1 = param1;
thecommand.param2 = param2;
(void)SndDoCommand( thechannel, &thecommand, false);
}
void soundchannel::sendImmediate( short cmd, short param1, long param2) const
{
SndCommand thecommand;
thecommand.cmd = cmd;
thecommand.param1 = param1;
thecommand.param2 = param2;
(void)SndDoImmediate( thechannel, &thecommand);
}